﻿using System.Windows.Forms;

namespace DimsMapper
{
    class BufferedPanel : Panel
    {
        // Set the value of the double-buffering style bits to true.
        public void EnableDoubleBuffering()
        {
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            //this.SetStyle(ControlStyles.Opaque, false);
            this.UpdateStyles();
        }

        //И добавим к окну, при его создании, стиль WS_EX_TRANSPARENT: 
        //protected override CreateParams CreateParams
        //{
        //    get
        //    {
        //        const int WS_EX_TRANSPARENT = 0x00000020;
        //        CreateParams createParams = base.CreateParams;
        //        createParams.ExStyle |= WS_EX_TRANSPARENT;
        //        return createParams;
        //    }
        //}

        public BufferedPanel()
        {
            EnableDoubleBuffering();
        }

        //protected override void OnPaint(PaintEventArgs e)
        //{
        //    base.OnPaint(e);
        //}

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            //base.OnPaintBackground(e);
        }
    }
}